package com.multi.tool.concurrent;

import java.util.concurrent.*;

/**
 * @author zhengpeng.wang
 */
public class Demo1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        final MyCallableDemo myCallable = new MyCallableDemo();
        final FutureTask<Integer> task = new FutureTask<>(myCallable);
        new Thread(task).start();
        System.out.println(task.get());

        final ExecutorService executorService = Executors.newSingleThreadExecutor();
        final Future<?> future = executorService.submit(myCallable);
        System.out.println(future.get());
        executorService.shutdown();
    }
}
